From: Florian Müllner Date: Wed, 8 Feb 2023 13:31:10 +0000 (+0100) Subject: status/bluetooth: Show connected devices in subtitle X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~405^2^2~33 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=b7c3a7f6eda9082375b81268b72b71e8a10ecea6;p=gnome-shell.git status/bluetooth: Show connected devices in subtitle Now that quick toggles support subtitles, use it to indicate connected devices. Part-of: --- diff --git a/js/ui/status/bluetooth.js b/js/ui/status/bluetooth.js index 4b828bd1e..2851f2d27 100644 --- a/js/ui/status/bluetooth.js +++ b/js/ui/status/bluetooth.js @@ -164,7 +164,27 @@ class BluetoothToggle extends QuickToggle { (bind, source) => [true, this._getIconNameFromState(source)], null); + this._client.connectObject( + 'devices-changed', () => this._sync(), + this); + this.connect('clicked', () => this._client.toggleActive()); + + this._sync(); + } + + _sync() { + const connectedDevices = [...this._client.getDevices()] + .filter(dev => dev.connected); + const nConnected = connectedDevices.length; + + if (nConnected > 1) + /* Translators: This is the number of connected bluetooth devices */ + this.subtitle = ngettext('%d Connected', '%d Connected', nConnected).format(nConnected); + else if (nConnected === 1) + this.subtitle = connectedDevices[0].alias; + else + this.subtitle = null; } _getIconNameFromState(state) {